package cn.edu.scau.cmi.yangjiamin.client;

import cn.edu.scau.cmi.yangjiamin.adapter.ClassAdapter;
import cn.edu.scau.cmi.yangjiamin.adapter.ObjectAdapter;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class AdapterGUI extends Application{
	@Override
	public void start(Stage primaryStage) {
		BorderPane pane = new BorderPane();
		HBox hbox = new HBox();
		hbox.setPadding(new Insets(10, 10, 10, 10));
		Button classad = new Button("类适配器实现变压");
		Button objectad = new Button("对象适配器实现变压");
		hbox.getChildren().addAll(classad, objectad);
		Text text =  new Text(100, 100, "显示结果");
		classad.setOnAction(e->{
			ClassAdapter ca = new ClassAdapter();
			text.setText("类适配器实现 " + ca.getBefore() + " 转换为 " + ca.getAfter());
		});
		
		objectad.setOnAction(e->{
			ObjectAdapter oa = new ObjectAdapter();
			text.setText("对象适配器实现" + oa.getBefore() + " 转换为 " + oa.getAfter());
		});
		pane.setTop(hbox);
		pane.setCenter(text);
		Scene scene = new Scene(pane, 600, 500);
		primaryStage.setTitle("AdapterGUI");
		primaryStage.setScene(scene);
		primaryStage.show();
	}

}
